home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 3010 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  47 lines

  1. Newsgroups: comp.lang.c
  2. Path: uu4news.netcom.com!friend!news
  3. From: rich@kastle.com (Richard Krehbiel)
  4. Subject: Re: Is it possible to #include <#defined or -D 'ed macro>?
  5. Message-ID: <1996Jan25.114826.28115@friend.kastle.com>
  6. Sender: news@friend.kastle.com (News)
  7. Reply-To: rich@kastle.com
  8. Organization: Kastle Development Associates
  9. X-Newsreader: Forte Free Agent 1.0.82
  10. References: <5rbuntgqp0.fsf@ritz.mordor.com>
  11. Date: Thu, 25 Jan 1996 11:48:07 GMT
  12.  
  13. benjamin@ritz.mordor.com (Joseph Thomas) wrote:
  14.  
  15. >Does anyone know a way of having an include statement that can include
  16. >a file, based on a -D <MACRO_NAME> flag passed to the compiler, to
  17. >give the effect of:
  18.  
  19.  
  20. >#include <SOURCE>
  21.  
  22. #include uses either the form
  23.  
  24. #include "file"
  25.  
  26.    or
  27.  
  28. #include <file>
  29.  
  30. The include directive is preprocessed first, so you can write
  31.  
  32. #include SOURCE
  33.  
  34. ...and so long as SOURCE is #defined to be in one of the two accepted
  35. forms, it will work.
  36.  
  37. I used this exact trick once in an OS/2 project.  Getting the quote
  38. characters as part of the defined symbol from the command line was a
  39. bit tricky.  I ended up with this in my makefile:
  40.  
  41.     $(CC) $(CFLAGS) /DAVL_DATATYPES="\"avl_mem.h\"" /C avlmem.c
  42.  
  43. --
  44. Richard Krehbiel, Kastle Systems, Arlington VA USA
  45. rich@kastle.com (work) or richk@mnsinc.com (personal)
  46.  
  47.